#!/bin/bash
#
#更新GIT到最新版本
#
echo "开始执行"
CMD_PATH=`dirname $0`
cd $CMD_PATH
echo "进入目录：$PWD"

WEB_USER='root'
WEB_USERGROUP='root'

#
# 未clone请先做一下clone
# 如git clone git@git.oschina.net:....
#

echo "拉取代码..."
git reset --hard HEAD
git clean -f
git pull

#处理数据库配置被覆盖
#rm -rf ./Conf/db.php
#cp -rf ./Conf/db.master.php ./Conf/db.php
echo "修改目录用户权限..."

#rm -rf ./Runtime/*

chmod -R 755 ./update-git.sh
chmod -R 777 ./storage/
chmod -R 777 ./nohup.out
chmod -R 755 ./public/uploads/

chown -R $WEB_USER:$WEB_USERGROUP ./storage/
chown -R $WEB_USER:$WEB_USERGROUP ./public/uploads/

echo "完成！！！"

